package com.demoworld;

import org.junit.Test;

/**
 * Created by francis on 2017/7/5.
 */
public class JLinkedListQueueTest {
    //正常的 push pop
    @Test
    public void test1() {
        JLinkedListQueue j = new JLinkedListQueue();
        for (int i = 1; i <= 2; i++) {
            j.push(i);
        }

        while (!j.isEmpty()) {
            System.out.println(j.pop());
        }
    }

    //超过最长长度
    @Test
    public void test2() {
        JLinkedListQueue j = new JLinkedListQueue();
        for (int i = 1; i <= 10; i++) {
            j.push(i);
            if (i == 5) {
                System.out.println(j.pop());
            }
        }

        while (!j.isEmpty()) {
            System.out.println(j.pop());
        }
    }

    //push pop混合操作
    @Test
    public void test3() {
        JLinkedListQueue j = new JLinkedListQueue();
        for (int i = 1; i <= 10; i++) {
            j.push(i);
            if (i == 5) {
                System.out.println(j.pop());
                j.push(12);
            }
        }

        while (!j.isEmpty()) {
            System.out.println(j.pop());
        }
    }
}
